#include "kfifo.h"
#include "kfifo_c.h"

struct kfifo_handle_t *kfifo_create(uint8_t *buffer, uint16_t size)
{
    struct kfifo_handle_t *handle = (struct kfifo_handle_t *)malloc(sizeof(struct kfifo_handle_t));
    kfifo *fifo = new kfifo(buffer, size);
    handle->cpp_handle = (void *)fifo;
    return handle;
}

size_t kfifo_put(struct kfifo_handle_t *handle, const uint8_t *ptr, size_t length)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_put(ptr, length);
}

size_t kfifo_put_force(struct kfifo_handle_t *handle, const uint8_t *ptr, size_t length)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_put_force(ptr, length);
}

size_t kfifo_get(struct kfifo_handle_t *handle, uint8_t *ptr, size_t length)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_get(ptr, length);
}

size_t kfifo_peek(struct kfifo_handle_t *handle, uint8_t **ptr)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_peek(ptr);
}

size_t kfifo_putchar(struct kfifo_handle_t *handle, const uint8_t ch)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_putchar(ch);
}

size_t kfifo_putchar_force(struct kfifo_handle_t *handle, const uint8_t ch)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_putchar_force(ch);
}

size_t kfifo_getchar(struct kfifo_handle_t *handle, uint8_t *ch)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_getchar(ch);
}

size_t kfifo_getchar_force(struct kfifo_handle_t *handle, uint8_t *ch)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_getchar_force(ch);
}

size_t kfifo_data_len(struct kfifo_handle_t *handle)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_data_len();
}

size_t kfifo_data_space_len(struct kfifo_handle_t *handle)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_data_space_len();
}

void kfifo_reset(struct kfifo_handle_t *handle)
{
    kfifo *fifo = (kfifo *)handle->cpp_handle;
    return fifo->kfifo_reset();
}
